<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ page import="java.sql.*"%>
<%@ page import="java.util.*"%>
<%@ page import="com.shopping.category.*"%>
<%@  include file="_sessioncheck.jsp" %>


<%
List<Category> categories = Category.getCategories();
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
  <table border="1" align="center">
    <tr>
      <td>ID</td>
      <td>Pid</td>
      <td>Name</td>
      <td>Grade</td>
      
      <td colspan="2" align="center">处理</td>
    </tr>
    <%
      for(Iterator<Category> it = categories.iterator();it.hasNext(); ) {
    	  Category c = it.next();
    	  
    	  String preStr = "";
    	  for(int i=1;i<c.getGrade();i++) {
    		  preStr += "----";
    	  }	  
    %>
    	  <tr>
    	    <td><%= c.getId() %></td>
    	    <td><%= c.getPid() %></td>
    	    <td><%= preStr + c.getName() %></td>
    	    <td><%= c.getGrade() %></td>
    	    
    	    
    	    <td><a href="categoryadd.jsp?pid=<%=c.getId() %>" >添加子类别</a></td>
    	    <td><a href="categorydelete.jsp?id=<%=c.getId() %>" >删除子类别</a></td>
    	  </tr>
    <%
      }
    %>
  </table>
</body>
</html>